package top.leyi.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import top.leyi.entity.Talk.Talk;

import java.util.Iterator;
import java.util.List;
import java.util.Set;

@Component
public class TalkCache {
  @Autowired
  StringRedisTemplate redisTemplate;

  public List<Talk> getHotTalk() {
      Set set = redisTemplate.opsForZSet().range("hotTalk",0, 10 );

      Iterator iterator = set.iterator();

      while (iterator.hasNext()) {
          System.out.println(iterator.next());
      }

      return null;
  }

  public void cacheHotTalk() {

  }

  public static void main(String[] args) {
       TalkCache cache = new TalkCache();
       cache.getHotTalk();
  }
}
